import axios from 'axios'
import stringutil from './stringutil.js';
const request = function(row) {
    return {
        "header": {
            "requestId": stringutil.getRandomNumber(32),
            "timeStamp": new Date().getTime(),
            "applicationId": "san-admin",
            "ip": "127.0.0.1"
        },
        "body": row
    }
}
const setObject = function(key, value) {
    value = JSON.stringify(value)
    return window.$localStorage.setItem(key, value)
}
const getObject = function(key) {
    return JSON.parse(window.window.$localStorage.getItem(key));
}
const inquiryOSSInfo = function() {
    var options = {}
    axios.post("/inquiryOSSInfo", this.request(options))
        .then(response => {
            if (response.data.body.status.statusCode == 0) {
                var data = response.data.body.data;
                this.setObject("ossinfo", data);
            } else {
                this.$Message.error(response.data.body.status.errorDesc);
            }
        }, response => {
            this.$Message.error('操作失败');
        })
}
const getOssInfo = function() {
    return this.getObject('ossinfo');
}

export default {
    request,
    setObject,
    getObject,
    inquiryOSSInfo,
    getOssInfo,
}
